﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Application;
using Traceability.App.Application.Dto.Input;
using Traceability.App.Domain.Model;
using Traceability.App.ErrorCode;

namespace Traceability.App.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HealthController : ControllerBase
    {
        private readonly IService service;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service">参数</param>
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service"></param>
        public HealthController(IService service)
        {
            this.service = service;
        }
        /// <summary>
        /// 添加保健信息
        /// </summary>
        /// <param name="input">参数</param>
        /// <returns>返回</returns>
        [HttpPost]
        public ApiResult<int> AddHealth(HealthInput input) 
        {
            return service.AddHealth(input);
        }
        /// <summary>
        /// 修改保健信息
        /// </summary>
        /// <param name="input">参数</param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateHealth(UpdateHealthInput input) 
        {
            return service.UpdateHealth(input);
        }

        /// <summary>
        /// 删除保健信息
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteHealth(int id) 
        {
            return service.DeleteHealth(id);
        }
        /// <summary>
        /// 获取保健信息
        /// </summary>
        /// <returns>返回信息数据</returns>
        /// <returns>返回数据</returns>
        [HttpGet]
        public ApiResult<List<HealthModel>> GetHealthShow(string batch) 
        {
            return service.GetHealthShow(batch);
        }
    }
}
